//
//  CBGMineViewController.m
//  chebabaGYS
//
//  Created by zhengminjie on 15/12/24.
//  Copyright © 2015年 zhengminjie. All rights reserved.
//

#import "CBGMineViewController.h"
#import "CBGMIneTableViewCell.h"
#import "CBGRepairViewController.h"
#import "CBGAppointmentViewController.h"
#import "CBGOrderViewController.h"
#import "CBGVehicleViewController.h"

@interface CBGMineViewController ()<UITableViewDelegate, UITableViewDataSource>{

    __weak IBOutlet UILabel *userLab;
    
    __weak IBOutlet UITableView *tableView_;
    
    NSArray *contentArr;        //有哪些我的
}

@end

@implementation CBGMineViewController

//返回的按钮
- (IBAction)backBtnAction:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    contentArr = @[@"我的抢修", @"我的预约", @"我的订单"];
    tableView_.delegate = self;
    tableView_.dataSource = self;
    tableView_.separatorStyle = UITableViewCellSeparatorStyleNone;
    userLab.text = [NSString stringWithFormat:@"用户:%@", @"12334567890"];
 
}

#pragma mark - UITableViewDatasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
     return contentArr.count;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{
     CBGMIneTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        // xib中注意指定identifier
        cell = [[NSBundle mainBundle] loadNibNamed:@"mine" owner:self options:nil][0];
        
        static int count = 0;
        NSLog(@"第%d个Cell被创建*****************", count++);
    }
    [cell setNeedsLayout];
    cell.label.text = contentArr[indexPath.row];
    cell.img_.image = [UIImage imageNamed:@"chizi01"];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.row == 0) {
        UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"CBGRepairViewController"];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 1) {
        
//        UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"CBGAppointmentViewController"];
//        [self.navigationController pushViewController:vc animated:YES];
        
        UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该功能暂未开放，敬请期待" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alter show];
    }

    if (indexPath.row == 2) {
        UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"CBGEvaluationViewController"];
        [self.navigationController pushViewController:vc animated:YES];
//        UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该功能暂未开放，敬请期待" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
//        [alter show];
    }

//    if (indexPath.row == 3) {
//        UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"CBGRepairViewController"];
//        [self.navigationController pushViewController:[CBGVehicleViewController new] animated:YES];
//    }

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
